package com.nes.rabbitmq.springboot.object;

import com.nes.rabbitmq.springboot.User;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by wdq on 17-3-13.
 */
@Service
public class SenderObject {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void sendObj() {
        System.out.println("user发送消息...");
        User u = new User();
        u.setAge(12);
        u.setName("张三");

        amqpTemplate.convertAndSend("spring-queue-object", u);
    }

    public void send() {
        System.out.println("user发送消息...");
        amqpTemplate.convertAndSend("spring-queue-object", "this is string message。。。。");
    }
}
